package com.qire.manhua.activity;

import android.os.Bundle;

import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.inject.Autowired;
import com.qire.common.constant.Navigation;
import com.qire.common.inject.EventControllerInjector;
import com.qire.common.inject.ViewModelInjector;
import com.qire.common.support.base.BaseActivity;
import com.qire.common.utils.ThemeUtil;
import com.qire.manhua.R;
import com.qire.manhua.controller.AccountsAssociatedAddController;
import com.qire.manhua.databinding.ActivityAccountsAssociatedAddBinding;
import com.qire.manhua.model.viewModel.impl.AccountsAssociatedAddViewModel;

import net.yslibrary.android.keyboardvisibilityevent.util.UIUtil;

import androidx.annotation.Nullable;

@RouteMapping(path = Navigation.Page.AccountsAssociatedAddPage)
public class AccountsAssociatedAddActivity extends BaseActivity<ActivityAccountsAssociatedAddBinding> {

    @Autowired(injector = ViewModelInjector.class)
    AccountsAssociatedAddViewModel viewModel;

    @Autowired(injector = EventControllerInjector.class)
    AccountsAssociatedAddController controller;

    @Override
    public int layoutRid() {
        return R.layout.activity_accounts_associated_add;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ThemeUtil.changeStatusBarLightOrDark(this, true, true);

        viewModel.onAddition(this, viewDataBinder());
        controller.onAddition(viewModel);

        viewModel.gotoPanel(0);
    }

    @Override
    public void finish() {
        UIUtil.hideKeyboard(this);
        if(viewModel.backPanel()) {
            super.finish();
        }
    }
}
